loop = eval(input())
list = []
for i in range(loop):
    str = input()
    list.append(str.split(sep=" "))
for i in range(loop):
    rowSum = 0
    for j in list[i]:
        rowSum += eval(j)
    print(rowSum, end=" ")
print()
for i in range(loop):
    colSum = 0
    for j in range(loop):
        colSum += eval(list[j][i])
    print(colSum, end=" ")
print()
xSum = 0
ySum = 0
for i in range(loop):
    for j in range(loop):
        if i == j: xSum += eval(list[i][j])
        if j == loop - i - 1: ySum += eval(list[i][j])
print(xSum)
print(ySum)
